<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>详情</title>
    <link rel="stylesheet" href="__STATIC__/common//phone/css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/common/phone/css/bootstrap.min.css"/>
    <link rel="stylesheet" href="__STATIC__/common/phone/css/mui.picker.min.css" />
    <link rel="stylesheet" href="__STATIC__/common/phone/css/select2.min.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/common/phone/css/style.css" />
    <!--引入图标样式-->
    <link rel="stylesheet" href="__STATIC__/admin/assets/font-awesome/css/font-awesome.min.css">
</head>
<!--查看详情-->
<style>
    /* 设置滚动条的样式 */
    ::-webkit-scrollbar {
        width: 1px;
        height: 10px;
    }

    /* 滚动槽 */
    ::-webkit-scrollbar-track {
        /*  -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);*/
        background-color: #f2f4f8;
        width: 0px;
    }

    ::-webkit-scrollbar-button {
        width: 0px;
        height: 0px;
        background-color: rgba(50, 50, 50, 0.05);
    }

    /* 滚动条滑块 */
    ::-webkit-scrollbar-thumb {
        background-color: rgba(50, 50, 50, 0.25);
        border: 2px solid transparent;
        border-radius: 10px;
        background-clip: padding-box;
    }

    ::-webkit-scrollbar-thumb:hover {
        background-color: #999;
    }

    ::-webkit-scrollbar-thumb:window-inactive {
        background: #fff;

    }
    .tab_pane_blue{
        height: 460px;
    }
    .tab_content_scroll, .tab_pane_blue{
        overflow-y:hidden;
    }
    .nav_tabs>li.active>a, .nav_tabs>li.active>a:hover, .nav_tabs>li.active>a:focus{
        background-color: #25b3f6;
    }
    @media (max-width: 374px) and (min-width: 320px){
        .nav_tabs>li>a {
            font-size: 12px;
            padding: 5px 7px;
        }
    }
    .box{
        padding: 10px;
    }
    .channel_items img{
        height: 18px;
    }
    .tab_pane_blue{
        background:none;
    }
    .revise_items select{
        box-shadow: none;
        border-bottom: 1px solid #66c1fb !important;
    }
    .revise_items textarea{
        line-height: 30px;
    }
    select{
        height: 30px;
        padding: 0;
        padding-left: 15px;
        box-shadow: none;
        border: 1px solid #ccc !important;
    }
    .w50{
        float: left;
        width: 50%;
    }
    .w100{
        float: left;
        width: 100%;
    }
    .tab-pane{
        height: 100%;
        overflow-y: auto;
    }
    .bottom_btn{
        width: 100%;
        height: 50px;
        padding: 10px;
        z-index: 999;
    }
    .invit_box{
        padding: 5px;
        border-bottom: 1px solid #d5eeff;
    }
    .per_rec_details{
        margin-top: 0;
    }
    .none{
        display: none;
    }
    .btn_definite{
        width: 100%;
    }
    .cont p{
        font-size: 12px;
    }
    .bottom_btn{
        width: 100%;
        height: 55px;
        padding: 10px;
    }
    .btn_definite{
        width: 100%;
        background: none;
    }
    .btn_definite button{
        width: 100%;
        background-color: #25b3f6;
        border-radius: 3px;
    }
    .btn_close button{
        border: 1px solid #25b3f6;
    }
    .w33{
        float: left;
        width: 33%;
    }
    #channel{
        background: #ccc;
    }
    #banji{
        background: #ccc;
    }
</style>
<body>

<div class="box">
    <div class="layer_content">
        <!-- Nav tabs -->
        <ul class="nav nav-tabs nav_tabs" role="tablist">
            <li role="presentation" class="tab_title active"><a href="#detail_order" aria-controls="home" role="tab" data-toggle="tab">订单详情</a></li>
            <li role="presentation" class="tab_title"><a href="#revise_order" aria-controls="profile" role="tab" data-toggle="tab">修改订单</a></li>
            <li role="presentation" class="tab_title"><a href="#store_order" aria-controls="profile" role="tab" data-toggle="tab">门店服务</a></li>
        </ul>

        <!-- Tab panes -->
        <div class="tab-content tab_content_scroll" style="height:450px;">
            <!--订单详情-->
            <div role="tabpanel" class="tab-pane active tab_pane_blue" id="detail_order">
                <div class="panel_block">
                    <div class="head_pic">
                        <img src="__STATIC__/common/phone/images/customer.png"/>
                        <span>基本信息</span>
                    </div>
                    <div class="detail_info">
                        <div class="info_items">
                            <label>姓名</label>
                            <span>{$data.name_z}</span>
                        </div>
                        <div class="info_items">
                            <label>性别</label>
                            <span>
                                {eq name="$data.gender_z" value="1"}男{/eq}
                                {eq name="$data.gender_z" value="0"}女{/eq}
                                {eq name="$data.gender_z" value="2"}未知{/eq}
                            </span>
                        </div>
                        {neq name="$data.phone_z" value=""}
                        <div class="info_items">
                            <label>电话</label>
                            <span>{$data.phone_z}</span>
                        </div>
                        {/neq}
                        {neq name="$data.wechat" value=""}
                        <div class="info_items">
                            <label>微信</label>
                            <span>{$data.wechat}</span>
                        </div>
                        {/neq}
                        {neq name="$data.qq" value=""}
                        <div class="info_items">
                            <label>QQ</label>
                            <span>{$data.qq}</span>
                        </div>
                        {/neq}
                        <div class="info_items" style="width: 100%;">
                            <label>建单时间</label>
                            <span>{$data.jdtime}</span>
                        </div>
                    </div>
                </div>
                <div class="panel_block">
                    <div class="head_pic">
                        <img src="__STATIC__/common/phone/images/channel.png"/>
                        <span>渠道信息</span>
                    </div>
                    <div class="detail_info">
                        <div class="channel_items">
                            <label>渠道来源</label>
                            <span><img src="{$data.channel_path_text}">&nbsp;{$data.source_text}</span>
                        </div>
                        <div class="channel_items">
                            <label>建单人员</label>
                            <span>{$data.jdry_text}</span>
                        </div>
                        <div class="channel_items">
                            <label>建单部门</label>
                            <span>{$data.jd_depar_text}</span>
                        </div>
                        <div class="full_items">
                            <label>渠道备注</label>
                            <span>{eq name="$data.qdbz" value="" }未填写{else/}{$data.qdbz}{/eq}</span>
                        </div>
                    </div>
                </div>
                <div class="panel_block">
                    <div class="head_pic">
                        <img src="__STATIC__/common/phone/images/advice.png"/>
                        <span>邀约信息</span>
                    </div>
                    <div class="detail_info">
                        <div class="advice_items">
                            <label>邀约客服</label>
                            <span>{$data.yykf_text}</span>
                        </div>
                        <div class="advice_items">
                            <label>业务分类</label>
                            <span>{$data.leibie_text}</span>
                        </div>
                        <div class="advice_items">
                            <label>追踪时间</label>
                            <span>{$data.zztime}</span>
                        </div>
                        <div class="advice_items">
                            <label>领单时间</label>
                            <span>{$data.yytime}</span>
                        </div>
                        <div class="advice_items">
                            <label>门店</label>
                            <span>{$data.mendian_text}</span>
                        </div>
                        <div class="full_items">
                            <label>邀约备注</label>
                            <span>{$data.yybz}</span>
                        </div>
                    </div>
                </div>
            </div>
            <!--修改订单-->
            <div role="tabpanel" class="tab-pane" id="revise_order">
                <div class="revise_container">
                    <form id="res_form">
                        <input type="hidden" name="id" value="{$data.id}" id="orderid">
                        <div class="form-group form_group_item">
                            <label>姓名</label>
                            <input type="text" disabled style="background: #eeeeee" name="name_z" class="form-control" value="{$data.name_z}">
                        </div>
                        <div class="form-group form_group_item">
                            <label>手机号码</label>
                            <input type="text" disabled style="background: #eeeeee" name="phone_z" class="form-control" value="{$data.phone_z}">
                        </div>
                        <div class="form-group form_group_item">
                            <label>微信号码</label>
                            <input type="text" disabled style="background: #eeeeee" name="wechat" class="form-control" value="{$data.wechat}">
                        </div>
                        <div class="form-group form_group_item" style="height: 50px;">
                            <label style="float: left;width: 100%">渠道来源</label>
                            <select class="w33" name="channel" disabled style="background: #eeeeee" id="channel">
                                {volist name='channel' id='va' }
                                <option {eq name="va.id" value="$data.channel"}selected="selected"{/eq} value="{$va.id}">{$va.title}</option>
                                {/volist}
                            </select>
                            <select class="w33" name="source" disabled  id="source" style="margin-left: -1px;background: #eeeeee">
                            </select>
                            <select class="w33" name="banji" id="banji" disabled style="margin-left: -1px;background: #eeeeee">
                            </select>
                        </div>
                        <div class="form-group form_group_item" id="xingqiji" style="height: 50px;display: none">
                            <label style="float: left;width: 100%">星期</label>
                            <select  name="xingqi" id="xingqi"  disabled style="margin-left: -1px;background: #eeeeee">
                                {volist name='xingqi' id='vo'}
                                <option value="{$vo}" {if condition="$data['xingqi']== $vo"} selected="selected" {else}{/if}>{$vo}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group form_group_item" disabled id="shangkeriqi" style="display: none">
                            <label style="float: left;width: 100%">上课时间与上课时间段</label>
                            <div class="w50">
                                <input type="text" name="shijianduan1"  disabled style="background: #eeeeee" class="form-control shijianduan1" value="{$data.shijianduan1}" id="shijianduan1" >
                            </div>
                            <div class="w50">
                                <input type="text" name="shijianduan2"  disabled style="background: #eeeeee" class="form-control shijianduan2" value="{$data.shijianduan2}" id="shijianduan2" >
                            </div>
                        </div>
                        <div class="form-group form_group_item">
                            <label>类型</label>
                            <select name="leibie"  disabled style="background: #eeeeee">
                                {volist name='leibie' id='info'}
                                <option  value="{$info.id}" {eq name="data.leibie" value="$info.id" } selected {/eq}>{$info.title}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group form_group_item">
                            <label>活动</label>
                            <select name="activity"  disabled style="background: #eeeeee">
                                <option value="">未选择</option>
                                {volist name='activity' id='info' }
                                <option value="{$info.id}"  {eq name="data.activity" value="$info.id" } selected {/eq}>{$info.title}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group form_group_item">
                            <label>意向度</label>
                            <select name="intention"  disabled style="background: #eeeeee">
                                <option value="">未选择</option>
                                {volist name='yixiang' id='info'}
                                <option value="{$info.id}"  {eq name="data.intention" value="$info.id" } selected {/eq}>{$info.title}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group form_group_item">
                            <label>预算</label>
                            <select name="budget"  disabled style="background: #eeeeee">
                                <option value="">未选择</option>
                                {volist name='yusuan' id='info'}
                                <option value="{$info.id}" {eq name="data.budget" value="$info.id" } selected {/eq}>{$info.title}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group form_group_item">
                            <label>意向拍摄次数</label>
                            <select name="intention_num"  disabled style="background: #eeeeee">
                                <option value="">未选择</option>
                                {volist name='int_num' id='info'}
                                <option value="{$info.id}" {eq name="data.intention_num" value="$info.id" } selected {/eq}>{$info.title}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group form_group_item">
                            <label>预计拍摄时间</label>
                            <select name="shot_range"  disabled style="background: #eeeeee">
                                <option value="">未选择</option>
                                {volist name='stimate' id='info'}
                                <option value="{$info.id}"  {eq name="data.shot_range" value="$info.id" } selected {/eq}>{$info.title}</option>
                                {/volist}
                            </select>
                        </div>
                        <div class="form-group form_group_item"  style="height: 50px;">
                            <label style="float: left;width: 100%">邀约人员</label>
                            <select class="w50" name="invitation_group"  disabled style="background: #eeeeee" id="group" {in name="diction" value="2,3"} disabled {/in}>
                            <option value="0">选择邀约组</option>
                            {volist name="sondepar" id="info"}
                            <option value="{$info.id}" {eq name="data.invitation_group" value="$info.id"} selected="selected" {/eq} >{$info.name}</option>
                            {/volist}
                            </select>
                            <select class="w50" name="invitation" id="invit"  disabled style="background: #eeeeee">
                                <option value="0">选择邀约人员</option>
                            </select>
                        </div>
                        <div class="form-group form_group_item" >
                            <label style="float: left;width: 100%">备注</label>
                            <textarea name="yybz" rows=""  disabled style="background: #eeeeee" cols="">{$data.yybz}</textarea>
                        </div>
                    </form>
                </div>
                <div class="bottom_btn" style="margin-bottom: 20px;">
                    <div class="btn_definite">
                        <button type="button" onclick="save()">保存修改</button>
                    </div>
                </div>
            </div>
            <!--门店服务-->
            <div role="tabpanel" class="tab-pane" id="store_order">
                <div class="invit_box">
                    <form id="storeform">
                        <input type="hidden" name="id" value="{$data.id}" id="id">
                        <input type="hidden" name="sales" value="{$user.id}">
                        <div class="form-group form_group_item">
                            <label>订单状态</label>
                            <select name="state" id="state">
                                <option value="" >未选择</option>
                                {volist name='state' id='info'}
                                {range name="info.id" value="12,13,14,15" type="in"}
                                <option value="{$info.id}" {eq name="data.channel" value="$info.id" } selected {/eq}>{$info.name}</option>
                                {/range}
                                {/volist}
                            </select>
                        </div>
                        <div>
                            <div id="state12" class="none">
                                <div class="form-group form_group_item">
                                    <label>未进店原因</label>
                                    <select name="nostore" class="dist">
                                        <option value="">未选择</option>
                                        {volist name="nostore" id="vq" }
                                        <option value="{$vq.id}" {if  condition="($data.state == '12')	AND	($vq.id ==	$data.nostore)	"} selected  {/if} >{$vq.title}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div id="state13" class="none">
                                <div class="form-group form_group_item">
                                    <label>进店流失原因</label>
                                    <select name="instoreyy"  class="dist">
                                        <option value="">未选择</option>
                                        {volist name="instoreyy" id="vq" }
                                        <option value="{$vq.id}" {if  condition="($data.state == '13')	AND	($vq.id ==	$data.instoreyy)	"} selected  {/if} >{$vq.title}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                            <div id="state15" class="none">
                                <div class="form-group form_group_item">
                                    <label>选择调度</label>
                                    <select name="mendian" class="dist">
                                        <option value="">未选择</option>
                                        {volist name="mendian" id="info"}
                                        <option value="{$info.id}"  {if  condition="($data.state == '15')	AND	($info.id	==	$data.mendian)	"} selected  {/if} >{$info.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                                <div class="form-group form_group_item">
                                    <label>支付方式</label>
                                    <select name="payment"  class="dist">
                                        <option value="">未选择</option>
                                        {volist name="payment" id="info"}
                                        <option value="{$info.id}"   {if  condition="($data.state == '15')	AND	($info.id	==	$data.payment)	"} selected  {/if}  >{$info.title}</option>
                                        {/volist}
                                    </select>
                                </div>
                                <div class="form-group form_group_item">
                                    <label>验证码</label>
                                    <input type="text"  name="code"  {eq name="data.state" value="15"} value="{$data.code}" {/eq}  placeholder="例:0000" class="dist">
                                </div>
                                <div class="form-group form_group_item">
                                    <label>订单编号</label>
                                    <input type="text"  name="order" {eq name="data.state" value="15"} value="{$data.order}" {/eq} placeholder="例:0001"  class="dist">
                                </div>
                                <div class="form-group form_group_item">
                                    <label>套系金额</label>
                                    <input type="text" {eq name="data.state" value="15"} value="{$data.amount}" {/eq} name="amount" placeholder="￥0.00" class="dist">
                                </div>
                                <div class="form-group form_group_item">
                                    <label>应收金额</label>
                                    <input type="text"  name="receivable"  {eq name="data.state" value="15"} value="{$data.receivable}" {/eq} placeholder="例:0001"  class="dist">
                                </div>
                                <div class="form-group form_group_item">
                                    <label>实收金额</label>
                                    <input type="text"  name="collected" {eq name="data.state" value="15"} value="{$data.collected}" {/eq}placeholder="例:0001"  class="dist" >
                                </div>
                            </div>
                            <div id="state14" class="none">
                                <div class="form-group form_group_item">
                                    <label>选择调度</label>
                                    <select name="mendian" class="dist">
                                        <option value="">未选择</option>
                                        {volist name="mendian" id="info"}
                                        <option value="{$info.id}"  {if  condition="($data.state == '14')	AND	($info.id	==	$data.mendian)	"} selected  {/if} >{$info.name}</option>
                                        {/volist}
                                    </select>
                                </div>
                                <div class="form-group form_group_item">
                                    <label>支付方式</label>
                                    <select name="payment"  class="dist">
                                        <option value="">未选择</option>
                                        {volist name="payment" id="info"}
                                        <option value="{$info.id}"   {if  condition="($data.state == '14')	AND	($info.id	==	$data.payment)	"} selected  {/if}  >{$info.title}</option>
                                        {/volist}
                                    </select>
                                </div>
                                <div class="form-group form_group_item">
                                    <label>验证码</label>
                                    <input type="text"  name="code"  {eq name="data.state" value="14"} value="{$data.code}" {/eq}  placeholder="例:0000" class="dist">
                                </div>
                                <div class="form-group form_group_item">
                                    <label>订单编号</label>
                                    <input type="text"  name="order" {eq name="data.state" value="14"} value="{$data.order}" {/eq} placeholder="例:0001"  class="dist">
                                </div>
                                <div class="form-group form_group_item">
                                    <label>套系金额</label>
                                    <input type="text"  name="amount" {eq name="data.state" value="14"} value="{$data.amount}" {/eq}placeholder="￥0.00" class="dist">
                                </div>
                                <div class="form-group form_group_item">
                                    <label>应收金额</label>
                                    <input type="text"  name="receivable"  {eq name="data.state" value="14"} value="{$data.receivable}" {/eq} placeholder="例:0001"  class="dist">
                                </div>
                                <div class="form-group form_group_item">
                                    <label>实收金额</label>
                                    <input type="text"  name="collected" {eq name="data.state" value="14"} value="{$data.collected}" {/eq}placeholder="例:0001"  class="dist" >
                                </div>
                            </div>
                        </div>

                        <div class="form-group form_group_item">
                            <label>备注</label>
                            <textarea name="msbz" rows="" cols="">{$data.msbz}</textarea>
                        </div>

                        <div class="bottom_btn" style="margin-bottom: 20px;">
                            <div class="btn_definite">
                                <button type="button" class="savelog" onclick="saveinvit()">保存</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="per_rec_details per_rec_details_1">
                    <h4 style="margin-bottom: 10px;font-size: 16px;">进店记录</h4>
                    <ul class="rec_details">

                        {if  condition="(is_array($store_log) AND (count($store_log) == 0))"}
                        <li>
                            暂无进店记录
                        </li>
                        {else/}
                        {volist name='store_log' id='ul'}
                        <li>
                            <div class="more">
                                <div class="cont">
                                    <p><label style="color: red;">{$ul.state_text}</label><span style="float: right;">操作时间：{$ul.time  | date='Y-m-d H:i:s',###}</span></p>
                                    {eq name="ul.state" value="12"}
                                    <p>未到店原因：{$ul.nostore_text}</p>
                                    {/eq}
                                    {eq name="ul.state" value="13"}
                                    <p>进店流失原因：{$ul.instoreyy_text}</p>
                                    {/eq}
                                    {in name="ul.state" value="14,15"}
                                    <p>调度：{$ul.mendain_text}</p>
                                    <p>支付方式：{$ul.payment_text}</p>
                                    <p>金牌单号：{$ul.order}</p>
                                    <p>套系金额：{$ul.amount}</p>
                                    <p>应收金额：{$ul.receivable}</p>
                                    <p>实收金额：{$ul.collected}</p>
                                    {/in}
                                    <p>门市备注：{$ul.msbz}</p>
                                </div>
                                <div class="date">
                                    <span>门店：{$ul.store_text}<span style="color:#d95223;">&emsp;门市：{$ul.sales_text}</span></span>
                                    &emsp;<span style="float: right;">【PC端操作】</span>

                                </div>
                            </div>
                        </li>
                        {/volist}
                        {/if}
                    </ul>
                </div>
            </div>

        </div>
    </div>
</div>
<script type="text/javascript" src="__STATIC__/common/phone/js/jquery-3.2.0.min.js" ></script>
<script type="text/javascript" src="__STATIC__/common/phone/js/bootstrap.min.js" ></script>
<!--引入layer插件-->
<script type="text/javascript" src="__STATIC__/common/layer/layer.js"></script>
<!--引入时间插件-->
<script type="text/javascript" src="__STATIC__/common/phone/js/mui.min.js" ></script>
<script type="text/javascript" src="__STATIC__/common/phone/js/mui.picker.min.js" ></script>
{include file='base/validate'}
<script>
    /*数据校验*/
    var fields ={
        name_z: {
            message: '用户名验证失败',
            validators: {
                notEmpty: {
                    message: '主要联系人不能为空'
                }
            }
        },
        phone_z: {
            message: '',
            validators: {
                regexp: {
                    regexp: /^1[3|5|8]{1}[0-9]{9}$/,
                    message: '请输入正确的手机号码'
                },
                threshold :  10 ,
                remote: {
                    type: "post",
                    url: '{:url(\'getContact\')}',
                    message: '当前号码已经存在',
                    delay: 1000,
                    data: function(validator) {
                        return {
                            name: $('[name="phone_z"]').attr('name'),
                            value: $('[name="phone_z"]').val(),
                            id : $('#orderid').val()
                        };
                    }
                }

            }
        },
        wechat: {
            message: '',
            enabled: true,
            validators: {
                threshold :  6 ,
                remote: {
                    type: "post",
                    url: '{:url(\'getContact\')}',
                    message: '当前号码已经存在',
                    delay: 2000,
                    data: function(validator) {
                        return {
                            name: $('[name="wechat"]').attr('name'),
                            value: $('[name="wechat"]').val(),
                            id : $('#orderid').val()
                        };
                    }
                }

            }
        },
        spare_phone: {
            message: '',
            enabled: true,
            validators: {
                regexp: {
                    regexp: /^1[3|5|8]{1}[0-9]{9}$/,
                    message: '请输入正确的手机号码'
                },
                threshold :  10 ,
                remote: {
                    type: "post",
                    url: '{:url(\'getContact\')}',
                    message: '当前号码已经存在',
                    delay: 1000,
                    data: function(validator) {
                        return {
                            name: $('[name="spare_phone"]').attr('name'),
                            value: $('[name="spare_phone"]').val(),
                            id : $('#orderid').val()
                        };
                    }
                }

            }
        },
        spare_wechat: {
            message: '',
            enabled: true,
            validators: {
                threshold :  6 ,
                remote: {
                    type: "post",
                    url: '{:url(\'getContact\')}',
                    message: '当前号码已经存在',
                    delay: 2000,
                    data: function(validator) {
                        return {
                            name: $('[name="spare_wechat"]').attr('name'),
                            value: $('[name="spare_wechat"]').val(),
                            id : $('#orderid').val()
                        };
                    }
                }

            }
        },
        rec_user:{
            message: '推荐人验证失败',
            validators: {
                notEmpty: {
                    message: '推荐人姓名不能为空'
                }
            }
        },
        rec_phone: {
            message: 'The phone is not valid',
            enabled: true,
            validators: {
                regexp: {
                    regexp: /^1[3|5|8]{1}[0-9]{9}$/,
                    message: '请输入正确的手机号码'
                },
                threshold :  10 ,
                remote: {
                    type: "post",
                    url: '{:url(\'getContact\')}',
                    message: '当前号码已经存在',
                    delay: 1000,
                    data: function(validator) {
                        return {
                            name: $('[name="rec_phone"]').attr('name'),
                            value: $('[name="rec_phone"]').val(),
                            id : $('#orderid').val()
                        };
                    }
                }

            }
        },
        rec_wechat: {
            message: 'The phone is not valid',
            enabled: true,
            validators: {
                threshold :  6 ,
                remote: {
                    type: "post",
                    url: '{:url(\'getContact\')}',
                    message: '当前号码已经存在',
                    delay: 2000,
                    data: function(validator) {
                        return {
                            name: $('[name="rec_wechat"]').attr('name'),
                            value: $('[name="rec_wechat"]').val(),
                            id : $('#orderid').val()
                        };
                    }
                }
            }
        },
    };
    var optionfields ={
        state: {
            message: '订单状态不能为空',
            validators: {
                notEmpty: {
                    message: '订单状态不能为空'
                }
            }
        },
        nostore: {
            message: '请选择未进店原因',
            validators: {
                notEmpty: {
                    message: '请选择未进店原因'
                }
            }
        },
        instoreyy: {
            message: '请选择进店流失原因',
            validators: {
                notEmpty: {
                    message: '请选择进店流失原因'
                }
            }
        },
        store: {
            message: '请选择调度或门店',
            validators: {
                notEmpty: {
                    message: '请选择调度或门店'
                }
            }
        },
        payment: {
            message: '请选择支付方式',
            validators: {
                notEmpty: {
                    message: '请选择支付方式'
                }
            }
        },
        code: {
            message: '请选择验证码',
            validators: {
                notEmpty: {
                    message: '请选择验证码'
                }
            }
        },
        amount: {
            message: '请选择套系金额',
            validators: {
                notEmpty: {
                    message: '请选择套系金额'
                }
            }
        },
        receivable: {
            message: '请选择应收金额',
            validators: {
                notEmpty: {
                    message: '请选择应收金额'
                }
            }
        },
        collected: {
            message: '请选择实收金额',
            validators: {
                notEmpty: {
                    message: '请选择实收金额'
                }
            }
        },
        order: {
            message: '请选择订单号',
            validators: {
                notEmpty: {
                    message: '请选择订单号'
                }
            }
        },
    }

    //页面初始化
    $(function () {
        //初始化选择订单状态
        $('#state').find("option[value='{$data.state}']").attr("selected",true);
        $('#state').find("option[value='{$data.state}']").trigger("change");

        //初始化来源
        var channel = "{$data.channel}";
        var source = "{$data['source']}";
        var obj = $('#source');
        getsource(channel, obj ,source ,true);

        //初始化邀约人员
        var id = "{$data['invitation_group']}";
        var divs = $('#invit');
        var invit = "{$data['invitation']}";
        if(id != ""){
            groupinvit(id, divs ,invit);
        }
        //初始化时间插件
        packtime('make_time');
        packtime('next_time');
        packtime('shot_time');


    })


    //更改渠道事件
    $('#channel').change(function () {
        var channel = $('#channel').val();
        var obj = $('#source');
        getsource(channel,obj);
    });
    //选择不同的订单状态
    $('#state').change(function () {
        console.log("a")
        if($(this).val() !=""){
            var id ='state'+$(this).val();
            var div = $('#'+id).children();
            var pardiv = $('#'+id).parent().children();

            //当前元素的所有兄弟元素加上
            for (var i = 0; i < pardiv.length - 1; i++) {
                $(pardiv[i]).find('.dist').attr('disabled', 'disabled');
            }
            //当前元素去掉
            for (var i = 0; i < div.length; i++) {
                $(div[i]).find('.dist').removeAttr('disabled');
            }
            $('#'+id).prevAll('.none').hide();
            $('#'+id).nextAll('.none').hide();
            $('#'+id).show();
        }else {
            $('.none').hide();
        }


    });

    //时间插件
    function packtime(vid) {
        $('#'+vid).click(function(){
            var dtPicker = new mui.DtPicker({
                "type": "datetime"
            });
            dtPicker.show(function (selectItems) {
                $('#'+vid).val(selectItems);
                $('#ser_form').data('bootstrapValidator')
                    .updateStatus(vid, 'NOT_VALIDATED',null)
                    .validateField(vid);
            });
        });
    }
    $('.shijianduan1').focus(function(){
        document.activeElement.blur();
    });
    $('.shijianduan2').focus(function () {
        document.activeElement.blur();
    })
    $('.shijianduan1').click(function () {
        var dtPicker = new mui.DtPicker({
            "type": "time"
        });
        dtPicker.show(function (selectItems) {
            $('.shijianduan1').val(selectItems)
        })
    })
    $('.shijianduan2').click(function () {
        var dtPicker = new mui.DtPicker({
            "type": "time"
        });
        dtPicker.show(function (selectItems) {
            $('.shijianduan2').val(selectItems)
        })
    })


    /*根据渠道获取来源*/
    function getsource(data, obj, source) {
        if (data != '') {
            $.post("{:url('common/getSourceByChennel')}", {channel: data}, function (result) {
                var html = "";
                obj.html('');
                if (result == '') {
                    html += "<option value='0'>暂无来源</option>";
                    obj.append(html);
                } else {
                    for (var i = 0; i < result.length; i++) {
                        if (source == result[i].id) {
                            html += "<option value=" + result[i].id + "  selected >" + result[i].title + "</option>"
                        } else {
                            html += "<option value=" + result[i].id + " >" + result[i].title + "</option>"
                        }
                    }
                    obj.append(html);
                }
            });
            var banji = $('#banji');
            $.post("{:url('common/getBanjiBySource')}", {source: data}, function (result) {
                var html = "";
                banji.html('');

                if (result == '') {
                    // $('#banjishow').hide();
                    $('#xingqiji').hide();
                    $('#shangkeriqi').hide();
                    html += "<option value='0' disabled>暂无班级</option>";
                    banji.append(html);
                }else if(result.code==0){
                    return false;
                } else {
                    // $('#banjishow').show();
                    $('#xingqiji').show();
                    $('#shangkeriqi').show();
                    $.each(eval(result), function (i, n) {
                        $("<option value='" + n.id + "' selected='selected'>" + n.banjiname + "</optinon>").appendTo(banji);
                    });
                }
            })
        } else {
            var html = "<option value='0'>暂无来源</option>";
            obj.html('').append(html);
        }
    }

    //推荐客资校验
    $('#res_form').bootstrapValidator({
        message: '',
        fields: fields
    });
    //邀约信息验证
    $('#storeform').bootstrapValidator({
        message: '',
        fields: optionfields
    });
    /*保存客资*/
    function save() {
        var formData = new FormData($("#res_form")[0]);
        var bootstrapValidator = $("#res_form").data('bootstrapValidator');
        bootstrapValidator.validate();
        if (bootstrapValidator.isValid()) {
            if(!$("[name='phone_z']").val() && !$("[name='wechat']").val()){
                $("[name='phone_z']").parent().parent('.tab').addClass('has-error');
                $("[name='wechat']").parent().parent('.tab').addClass('has-error');
                return layer.msg("联系人电话或微信必填其一", {icon: 0});
            }else {
                $("[name='phone_z']").parent().parent('.tab').removeClass('has-error');
                $("[name='wechat']").parent().parent('.tab').removeClass('has-error');
            }
            $.ajax({
                type: "POST",
                url:  "{:url('edit')}",
                data: formData,
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                beforeSend:function(){
                    $(this).attr("disabled","false"); //禁止点击
                },
                success: function(data){
                    layer.msg(data.info, {icon: data.status});
                    setTimeout(function(){
                        $(this).attr("disabled","false"); //禁止点击
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        window.parent.location.reload();
                    },2000); //延迟演示

                }
            });
            return false;
        } else return;
    }
    /*保存门店服务记录*/
    function saveStore() {
        var formData = new FormData($("#storeform")[0]);

    }
    //保存邀约信息
    function saveinvit() {
        var formData = new FormData($("#storeform")[0]);
        var bootstrapValidator = $("#storeform").data('bootstrapValidator');
        bootstrapValidator.validate();
        if (bootstrapValidator.isValid()) {
            $.ajax({
                type: "POST",
                url: "{:url('saveStore')}",
                data: formData,
                async: false,
                cache: false,
                contentType: false,
                processData: false,
                beforeSend:function(){
                    $('.btn-primary').attr("disabled","false"); //禁止点击
                },
                success: function (data) {
                    layer.msg(data.info, {icon: data.status});
                    setTimeout(function () {
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                        window.parent.location.reload();
                    }, 2000); //延迟演示

                }
            });
            return false;
        } else return;
    }
    /*修改客资获取对应的邀约组员*/
    $('#group').change(function () {
        var id = $('#group').val();
        var divs = $('#invit');
        groupinvit(id, divs);
    });
    //邀约人员获取
    function groupinvit(id, obj ,invit){
        $.post("{:url('common/getuserByGroup')}", {depart_id: id}, function (result) {
            var html = '';
            obj.html('');
            if (id == '0' | id=="") {
                html += "<option value=''>未分配邀约</option>";
            } else {
                if(result.length !=0){
                    html += "<option value=''>未分配邀约</option>";
                    for (var i in result) {
                        if (invit == result[i].id) {
                            html += "<option value='" + result[i].id + "' selected  >" + result[i].username + "</option>";
                        } else {
                            html += "<option value='" + result[i].id + "'>" + result[i].username + "</option>";
                        }
                    }
                }else {
                    html += "<option disabled>暂无邀约人员</option>";
                }

            }
            obj.append(html);
        });

    }

    /*点击取消按钮*/
    $('#cancel_btn').click(function () {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    });

</script>
</body>
</html>